<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Countdown to arrival</title>
        <link rel="stylesheet" href="css/style.css">
    </head>
    <body>
        <div class="container">
             <h2><span>距离小严宝贝抵达还有</span> 2023-02-20 18:08</h2>
             <div class="countdown">
                 <div id="day">NA</div>
                 <div id="hour">NA</div>
                 <div id="minute">NA</div>
                 <div id="second">NA</div>
             </div>
         </div>
    </body>
</html>
<script type="text/javascript">
    function getEndTime(myYear){
        var myEndTime = new Date(''+myYear+'/02/20 18:08:00');
        return myEndTime;
    }
    function countDown(){
        var mydate = new Date();
        var year = '2023';
        var EndTime = getEndTime(year);
        var NowTime = new Date();
        if( (EndTime.getTime() - NowTime.getTime() ) < 0){
            year = mydate.getFullYear() + 1;
            EndTime = getEndTime(year);
        }
        var t = EndTime.getTime() - NowTime.getTime();
        var d=Math.floor(t/1000/60/60/24);
        var h=Math.floor(t/1000/60/60%24);
        var m=Math.floor(t/1000/60%60);
        var s=Math.floor(t/1000%60);
        document.getElementById('day').innerText = d;
        document.getElementById('hour').innerText = h;
        document.getElementById('minute').innerText = m;
        document.getElementById('second').innerText = s;
    }
    setInterval(countDown,1000);
</script>